<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateCustomerSendCouponFailLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customer_send_coupon_fail_logs', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('userId')->default(0)->comment('用户id');
            $table->unsignedBigInteger('activityId')->default(0)->comment('活动id');
            $table->unsignedTinyInteger('activityType')->default(0)->comment('活动类型 1 ：绑定有礼');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->index('userId','idx_userId');
            $table->index('activityId','idx_activityId');
        });


        $prefix = config('other.DB_PREFIX', '');
        DB::statement("ALTER TABLE `{$prefix}customer_send_coupon_fail_logs` COMMENT = '用户发券失败记录表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customer_send_coupon_fail_logs');
    }
}
